//
//  switchBar.h
//  Etion
//
//  Created by hua ouyang on 11-10-17.
//  Copyright 2011年 __MyCompanyName__. All rights reserved.
//

#import <UIKit/UIKit.h>

typedef enum SwitchBarTitleCellViewDirection
{
    ESWitchBarDirectionTop,
    ESWitchBarDirectionRight,
    ESWitchBarDirectionBottom,
    ESWitchBarDirectionLeft
}ESWitchBarDirection;

@class CSwitchBarTitleCellView;
@protocol SwitchBarCellViewDelegate <NSObject>

- (void)didSelected:(CSwitchBarTitleCellView*)titleCellView;

@end

@interface CSwitchBarTitleCellView : UIView {
    NSString            *m_title;
    ESWitchBarDirection m_direction;
    UIFont              *m_font;
    UIFont              *m_selectedFont;
    UIColor             *m_titleColor;
    UIColor             *m_backgroundColor;
    UIColor             *m_titleSelectedColor;
    UIColor             *m_backgroundSelectedColor;
    BOOL                m_isSelected;
    NSMutableArray      *m_pointArray;
    CGRect              m_textRect;
    CGPoint             m_P1;
    CGPoint             m_P2;
    CGPoint             m_P3;
    CGPoint             m_P4;
    int                 m_index;
    id<SwitchBarCellViewDelegate>   m_delegate;
    UIImage             *m_bottomLineImage;
    UIImage             *m_backImage;
    UIImage             *m_backSelectedImage;
    BOOL                m_isUsedImage;
}
@property(nonatomic, copy)NSString *m_title;
@property(nonatomic, assign)ESWitchBarDirection m_direction;
@property(nonatomic, retain)UIFont *m_font;
@property(nonatomic, retain)UIFont *m_selectedFont;
@property(nonatomic, retain)UIColor *m_titleColor;
@property(nonatomic, retain)UIColor *m_backgroundColor;
@property(nonatomic, retain)UIColor *m_titleSelectedColor;
@property(nonatomic, retain)UIColor *m_backgroundSelectedColor;
@property(nonatomic, assign)BOOL m_isSelected;
@property(nonatomic, assign)int m_index;
@property(nonatomic, assign)id<SwitchBarCellViewDelegate> m_delegate;
@property(nonatomic, retain)UIImage *m_bottomLineImage;
@property(nonatomic, retain)UIImage *m_backImage;
@property(nonatomic, retain)UIImage *m_backSelectedImage;

- (id)initWithTitle:(NSString *)title rect:(CGRect)rect;

- (void)initDrawPointArrayAndTextRect;

- (void)backgroundImage:(UIImage*)backImage selected:(UIImage*)selectedImage bottomLine:(UIImage*)lineImage;

@end

@class CSwitchBar;
@protocol CSwitchBarDelegate <NSObject>

//- (CGFloat)switchBar:(CSwitchBar *)switchbar widthForTitleAtIndex:(NSUInteger)index;

- (void)switchBar:(CSwitchBar *)switchbar didSelectTitleAtIndex:(NSUInteger)index;

@end


//@protocol CSwitchBarDataSource;
@interface CSwitchBar : UIView<SwitchBarCellViewDelegate>
{
    UIScrollView        *m_backview;
    UIImageView         *m_leftView;
    UIImageView         *m_rightView;
    int                 m_currentIndex;
    CSwitchBarTitleCellView *m_currentSwitchView;
    
    NSMutableArray      *m_titleArray;
    //id<CSwitchBarDataSource>    *m_dataSource;
    id<CSwitchBarDelegate>  m_delegate;
}

@property(nonatomic, retain) NSMutableArray *m_titleArray;
@property(nonatomic, assign)id<CSwitchBarDelegate> m_delegate;

- (id)initWithFrame:(CGRect)frame titleArray:(NSMutableArray *)array index:(int)index;

@end

//
//@protocol CSwitchBarDataSource <NSObject>
//@required
//-(NSUInteger)switchBarNumberOfTitle:(CSwitchBar *)switchbar;
//
//-(NSString*)switchBar:(CSwitchBar *)switchbar titleForIndex:(NSUInteger)index;
//
//@optional
//- (NSInteger)indexSelected:(CSwitchBar *)switchbar;
//@end

